package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkEmployeeContract;
import com.ysd.lis.entity.WkEmployeeEducation;
import com.ysd.lis.mapper.WkEmployeeContractMapper;
import com.ysd.lis.service.WkEmployeeContractService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 员工档案-合同表 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-02-23
 */
@Service
public class WkEmployeeContractServiceImpl extends ServiceImpl<WkEmployeeContractMapper, WkEmployeeContract> implements WkEmployeeContractService {

    @Autowired
    WkEmployeeContractMapper wkEmployeeContractMapper;

    @Override
    public Result getEmployeeContractList(String wkEmployeeId) {
        LambdaQueryWrapper<WkEmployeeContract> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WkEmployeeContract::getDelFlag, 0)
                .eq(WkEmployeeContract::getWkEmpId, wkEmployeeId);
        List<WkEmployeeContract> wkEmployees = wkEmployeeContractMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功！", wkEmployees);
    }

    @Override
    public Result addEmployeeContract(WkEmployeeContract wkEmployeeContract) {
        boolean save = this.save(wkEmployeeContract);
        if (save) {
            return Result.succ(1, "添加成功", null);
        } else {
            return Result.fail("添加失败");
        }
    }

    @Override
    public Result updateEmployeeContract(WkEmployeeContract wkEmployeeContract) {
        boolean save = this.updateById(wkEmployeeContract);
        if (save) {
            return Result.succ(1, "编辑成功", null);
        } else {
            return Result.fail("编辑失败");
        }
    }

    @Override
    public Result deleteEmployeeContract(WkEmployeeContract wkEmployeeContract) {
        boolean b = this.removeById(wkEmployeeContract.getId());
        if (b) {
            return Result.succ(1, "删除成功", null);
        } else {
            return Result.fail("删除失败");
        }
    }
}
